﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Windows.Forms.Extensions.Appearance;
using System.Windows.Forms.Extensions.Model;

namespace ShutterNotifyerTestApplication.Forms
{
    /// <summary>
    /// Main test form
    /// </summary>
    public partial class FreestyleForm : Form
    {

        #region Events

        private void btnNotifiTextbox_Click(object sender, EventArgs e)
        {
            MapAndShowNotifier2();
        }

        private void btnNotify_Click(object sender, EventArgs e)
        {
            MapAndShowNotifier();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            InitializeComboboxes();
        }

        #endregion
        
        /// <summary>
        /// Killer app - animate!
        /// </summary>
        private void MapAndShowNotifier()
        {
            // Get new properties to override desig time values
            MapComboboxValuesToProperties();

            //
            // CALL SHUTTER NOTIFIER
            //
            this.shutterNotifier1.In("One field is missing. Blah blah blah-blah blah blah."
                                     , "Some additional test text."
                                     //, new List<string> { "Name is required", "Do not try to give 'Gandalf' as mother" }
                                     , new List<WarningItem> {new WarningItem("Name is required", this.textBox5)}
                                    );
        }

        /// <summary>
        /// Inline textarea notifier
        /// </summary>
        private void MapAndShowNotifier2()
        {
            //
            // CALL SHUTTER NOTIFIER
            //
            this.shutterNotifier2.In("We need your feedback."
                                    );
        }

        #region Other private methods

        private void MapComboboxValuesToProperties()
        {
            if (cmbAnimation.SelectedItem != null) this.shutterNotifier1.Animation = (Constants.Animations)cmbAnimation.SelectedValue;
            if (cmbIcon.SelectedItem != null) this.shutterNotifier1.Icon = (Constants.Icons)cmbIcon.SelectedValue;
            if (cmbTheme.SelectedItem != null) this.shutterNotifier1.Theme = (Constants.Themes)cmbTheme.SelectedValue;
            if (cmbConcealmentMethod.SelectedItem != null) this.shutterNotifier1.ConcealmentMethod = (Constants.ClickableControls)cmbConcealmentMethod.SelectedValue;
        }

        #endregion

        #region Constructor & combobox init

        private void InitializeComboboxes()
        {
            this.cmbAnimation.DataSource = Enum.GetValues(typeof(Constants.Animations));
            this.cmbIcon.DataSource = Enum.GetValues(typeof(Constants.Icons));
            this.cmbTheme.DataSource = Enum.GetValues(typeof(Constants.Themes));
            this.cmbConcealmentMethod.DataSource = Enum.GetValues(typeof(Constants.ClickableControls));

            this.cmbIcon.SelectedIndex = 1;
            this.cmbAnimation.SelectedIndex = 1;
        }

        public FreestyleForm()
        {
            InitializeComponent();
        }

        #endregion

    }
}
